oo::class create Indent {
    superclass Plugin
    variable Language RenamedPadWidget

    constructor {renamedPadWidget language} {
        set RenamedPadWidget $renamedPadWidget
        set Language $language

        bind [string trimleft $RenamedPadWidget _] <Tab> "+
            $Language updateIndentByTabEvent $RenamedPadWidget \[$RenamedPadWidget index {insert linestart}\]
            return -code break"
    }

    method old_updateIndentAfterInsert {index content args} {
        # It is very slow
        set lineNum [llength [split $content \n\r]]
        set i 1
        while {$i < $lineNum} {
            $Language updateIndent $RenamedPadWidget [$RenamedPadWidget index $index+${i}l]
            incr i
        }
    }

    method updateIndentAfterInsert {index content args} {
        if {[llength [split $content \r\n]] > 1} {
            $Language updateIndent $RenamedPadWidget [$RenamedPadWidget index $index+1l]
        }
    }

    method getPluginEvents {} {
        return {
            {afterInsert updateIndentAfterInsert}
        }
    }
}